/**
 * Copyright (c) 2020-2021 浦东大爷 All rights reserved.
 * 机会永远都是留给有准备的人
 */
package com.lagou.service.impl;

import com.lagou.mapper.AccountMapper;
import com.lagou.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: gitwo
 * @date: 2021-03-08
 * @description:
 */
@Service
@Transactional  //事务控制
public class AccountServiceImpl implements IAccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public int transfer(String inName, String outName, double money) {
        try {
            accountMapper.transferIn(inName, money);
            accountMapper.transferOut(outName, money);
            return 0;
        } catch (Exception e) {
            System.out.println(e);
            return 1;
        }
    }
}
